package com.xuan.controller.sys;

import com.xuan.configuration.result.ResponseResult;
import com.xuan.configuration.result.ResponseResultEnum;
import com.xuan.service.sys.SysCountService;
import com.xuan.vo.sys.SysCountVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统统计Controller
 */
@RestController
@RequestMapping("/sysCount")
public class SysCountController {

    @Autowired
    private SysCountService sysCountService; // 系统统计Service

//********************************************************************************************************************************

    /**
     * 增加1次总访问数
     */
    @GetMapping("/saveVisitsNumber")
    public ResponseResult saveVisitsNumber() {

        sysCountService.saveVisitsNumber();
        return ResponseResult.result(ResponseResultEnum.SAVE_SUCCESS);

    }

    /**
     * 增加1次总使用数
     */
    @GetMapping("/saveUsageNumber")
    public ResponseResult saveUsageNumber() {

        sysCountService.saveUsageNumber();
        return ResponseResult.result(ResponseResultEnum.SAVE_SUCCESS);

    }

    /**
     * 增加1次总访问数并返回总访问数、总使用数
     */
    @GetMapping("/saveVisitsNumberGet")
    public ResponseResult<SysCountVo> saveVisitsNumberGet() {

        SysCountVo vo = sysCountService.saveVisitsNumberGet();
        return ResponseResult.result(ResponseResultEnum.SAVE_SUCCESS, vo);

    }

    /**
     * 增加1次总使用数并返回总访问数、总使用数
     */
    @GetMapping("/saveUsageNumberGet")
    public ResponseResult<SysCountVo> saveUsageNumberGet() {

        SysCountVo vo = sysCountService.saveUsageNumberGet();
        return ResponseResult.result(ResponseResultEnum.SAVE_SUCCESS, vo);

    }

    /**
     * 查询总访问数、总使用数
     *
     * @return 总访问数、总使用数
     */
    @GetMapping("/getNumber")
    public ResponseResult<SysCountVo> getNumber() {

        SysCountVo vo = sysCountService.getNumber();
        return ResponseResult.result(ResponseResultEnum.GET_SUCCESS, vo);

    }


}
